package com.kgc.storeprovider.service.impl;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.InventoryCheckDetail;
import com.kgc.store.pojo.OutStoreDetail;
import com.kgc.storeprovider.dao.InventoryCheckDetailMapper;
import com.kgc.storeprovider.dao.OutStoreDetailMapper;
import com.kgc.storeprovider.service.InventoryCheckDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryCheckDetailServiceImpl implements InventoryCheckDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private InventoryCheckDetailMapper inventoryCheckDetailMapper;

    @Override
    public ResponseMsg getInventoryCheckDetailList(String inventoryCheckCode) {
        logger.info("InventoryCheckDetailServiceImpl getInventoryCheckDetailList inventoryCheckCode:"+inventoryCheckCode);
        ResponseMsg msg = new ResponseMsg();
        List<InventoryCheckDetail> inventoryCheckDetailList = inventoryCheckDetailMapper.getInventoryCheckDetailList(inventoryCheckCode);
        logger.debug("InventoryCheckDetailServiceImpl getInventoryCheckDetailList inventoryCheckDetailList:"+inventoryCheckDetailList);
        msg.setCode("200");
        msg.setData(inventoryCheckDetailList);
        logger.debug("InventoryCheckDetailServiceImpl getInventoryCheckDetailList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delInventoryCheckDetail(String inventoryCheckCode) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = inventoryCheckDetailMapper.delInventoryCheckDetail(inventoryCheckCode);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg insertInventoryCheckDetail(InventoryCheckDetail inventoryCheckDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = inventoryCheckDetailMapper.insertInventoryCheckDetail(inventoryCheckDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }
}
